<template>
  <div style="text-align: left; margin-top: 10px">
    <el-dropdown>
      <!-- <el-button type="primary" @click="">
                分类<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button> -->
      <el-button type="primary" @click="add">新增</el-button>
      <!-- <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>姓名</el-dropdown-item>
                <el-dropdown-item>账号</el-dropdown-item>
                <el-dropdown-item>密码</el-dropdown-item>
                <el-dropdown-item>权限</el-dropdown-item>
            </el-dropdown-menu> -->
    </el-dropdown>
    <el-main style="padding-left: 0px; padding-top: 0px">
      <el-table :data="Users" border style="width: 100%">
        <el-table-column prop="userid" label="id" width="200px">
        </el-table-column>
        <el-table-column prop="username" label="账号" width="200px">
        </el-table-column>
        <el-table-column
          prop="password"
          label="登陆密码"
          width="200px"
        ></el-table-column>
        <el-table-column
          prop="quanxian"
          label="权限"
          width="200px"
        ></el-table-column>

        <el-table-column label="操作" width="240px">
          <template slot-scope="">
            <el-button
              style="padding: 3px, 4px, 3px, 4px; margin: 2px"
              @click="update"
              >修改</el-button
            >
            <el-button
              style="padding: 3px, 4px, 3px, 4px; margin: 2px"
              @click="delUser"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="block" style="text-align: center">
        <el-pagination layout="prev, pager, next" :total="50"> </el-pagination>
      </div>
    </el-main>
    <el-form :model="user" ref="userFrom" style="margin: 0px; padding: 0px">
      <div style="text-align: left">
        <el-dialog
          style="padding: 0px"
          width="25%"
          :visible.sync="dialogVisible"
        >
          <el-row>
            <el-col :span="20">
              <div>
                <el-form-item label="账号">
                  <el-input
                    v-model="user.username"
                    style="width: 200px; height: 20px"
                    placeholder="请输入账号"
                  ></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <div>
                <el-form-item label="密码">
                  <el-input
                    v-model="user.password"
                    style="width: 200px; height: 20px"
                    placeholder="请输入密码"
                  ></el-input>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="20">
              <div>
                <el-form-item label="权限">
                  <el-select
                    v-model="user.quanxian"
                    style="width: 200px; height: 20px"
                    placeholder="请设置权限"
                  >
                    <el-option label="高级管理员" value="boss"></el-option>
                    <el-option label="管理员" value="root"></el-option>
                    <el-option label="用户" value="user"></el-option>
                    <el-option label="观察者" value="guancha"></el-option>
                  </el-select>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
          <span slot="footer">
            <el-button @click="cancel">取消</el-button>
            <el-button @click="save" type="primary">保存</el-button>
          </span>
        </el-dialog>
      </div>
    </el-form>
  </div>
</template>
<script>
export default {
  name: "yonghu",
  data() {
    return {
      Users: [],
      user: {
        userid: " ",
        username: " ",
        password: " ",
        quanxian: " ",
      },
      username: "",
      dialogVisible: false,
    };
  },
  created() {
    this.getJson();
  },

  methods: {
    getJson() {
      var usr = "";
      this.$axios.get("static/yonghuxinxi.json").then((res) => {
        console.log("获取表格");
        console.log(res.data);
        this.Users = res.data;
      });
    },
    add() {
      console.log("新增功能");
      this.dialogVisible = true;
    },
  },
};
</script>